[<<Previous Entry]
[^^Up^^]
[Next Entry>>]
[Menu]
[About The Guide]
~ Bitwise NOT operator (unary)
~exp bitwise NOT
exp any integral type (int, char, enum, etc)
The unary operator ~ performs a bit-by-bit complement on exp,
converting each 0 bit to a 1 and each 1 bit to a 0. The result is of
the same type as exp. For string expressions, the bit-by-bit
complement is performed on each character of the string. For numeric
expressions, the result of the expression is first converted to an
integer value and the complement operation performed. For example:
j = 3953; # j == 0x0F71 = 0000111101110001 (base 2)
i = ~j; # i == 0xF08E = 1111000010001110 (base 2)
This page created by ng2html v1.05, the Norton guide to HTML conversion utility.
Written by Dave Pearson